<%- include header%>
<% arts.forEach(function(art) { %>

	<div class="article">
		<a href="/u/<%= art.author%>/<%= art._id%>">
			<h1><%= art.title %></h1>
		</a>
		<p>
			<span class="author">
				<span class="text-bold">作者： </span>
				<a href="/u/<%= art.author%>"><%= art.author %></a>
				<!-- <%= art.author %> -->
			</span> |
			<span class="create-time">
				<span class="text-bold">时间： </span>
				<%= moment(art.createTime).format('LL HH:mm:ss') %>
			</span> | 
			<span class="pv">
				<span class="text-bold">浏览： </span>
				<%= art.pv %>
			</span> |
			<span class="tag"><%= art.tag %></span>
		</p>
		<p></p>
		<p></p>
		<p><%= art.content %></p>

		<% if (user) {%>
		    <% if(art.author==user.username) {%>
		        <div class="control">
		        	<a href="/remove/<%= art._id%>" class="pull-right remove">删除</a>
		        	<a href="/edit/<%= art._id%>" class="pull-right edit">编辑</a>
		        </div>
		    <% } %>
		<%}%>
	</div>
<%});%>

<nav>
	<ul class="pager">
		<% if (!isFirstPage) {%>
			<li>
				<a href="?page=1">
					<span aria-hidden="true">首页</span>
				</a>
			</li>

			<li>
				<a href="?page=<%= page -1 %>" aria-label="Previous">
					<span aria-hidden="true">&laquo;上一页</span>
				</a>
			</li>
		<% } %>
		<% if (!isLastPage) {%>
			<li>
				<a href="?page=<%= page+1%>" aria-label="Next">
					<span aria-hidden="true">下一页 &raquo;</span>
				</a>
			</li>
			<li>
				<a href="?page=<%= Math.ceil(total/pageSize) %>">
				<span aria-hidden="true">末页</span>	
				</a>				
			</li>
		<% } %>
		
		
	</ul>
</nav>

<div id="pagination-box"></div>

<div id="blog-data" 
data-total="<%= total %>"
data-page="<%= page %>"
data-pageSize="<%= pageSize %>"
data-isFirstPage="<%= isFirstPage %>"
data-isLastPage="<%= isLastPage %>">	
</div>
<script src="../public/view-js/pagination.js"></script>
<%- include footer%>